import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts
import "./tools/regex_utils.js" as RegexUtils

// TextField - ID Card Validator
Rectangle {
    Layout.fillWidth: true
    Layout.fillHeight: true

    Column {
        spacing: 10
        anchors.centerIn: parent
        width: parent.width * 0.8

        // IP 地址输入框
        TextField {
            id: idTextField
            width: parent.width * 0.8
            height: 30
            placeholderText: "输入身份证号"

            // 背景框
            background: Rectangle {
                border.color: "#c0c0c0"
                border.width: 1
                radius: 4
            }

            // 文本改变时进行校验
            onTextChanged: {
                RegexUtils.validateIDCard(text);
            }
        }

        // 用于显示校验结果的 Label
        Label {
            id: idStatus
            text: "输入身份证号"
            font.pointSize: 10
            wrapMode: Label.WordWrap
        }
    }
}
